package inherit;

import java.sql.SQLOutput;

class Animal {
    private String race;
    String name;
    int age;

    public void eat() {
        System.out.println(name + "吃饭");
    }
    public void sleep() {
        System.out.println(name + "睡觉");
    }

    public String getRace() { //访问private修饰的变量
        return race;
    }
}
class Cat extends Animal{
    public void CatchMouse() {
        System.out.println(name + "抓老鼠");
        //race = "cat"; erro 无法访问private限定符修饰的变量

    }
}
class Dog extends Animal{
    public void bark() {
        System.out.println(name + "汪汪汪");
    }
}
public class Test {
    public static void main(String[] args) {
        Cat cat = new Cat();
        cat.name = "mm";
        System.out.println(cat.name);
        cat.CatchMouse();
    }
}
